<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<c:set var="path" value="..${ctx}/define/judge"/>
<div class="pageContent">
	<form name="define_judge_edit" method="post" action="${path}/save.html" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
		<div class="pageFormContent" layoutH="56">
			<fieldset>
				<dl>
					<dt>判断类型：</dt>
					<dd>
						<select class="combox" name="type" >
							<option value="1" <c:if test="${bean.type==1}">selected</c:if> >工作组</option>
							<option value="2" <c:if test="${bean.type==2}">selected</c:if> >角色</option>
							<option value="3" <c:if test="${bean.type==3}">selected</c:if>>用户</option>
							<option value="4" <c:if test="${bean.type==4}">selected</c:if>>数据</option>
						</select>
					</dd>
				</dl>
				<dl>
					<dt>数据项名称：</dt>
					<dd><input name="dataName" type="text" size="30" value="${bean.dataName}" onchange="setExpression();" />
						<input name="id" type="hidden" value="${bean.id}" />
					</dd>
				</dl>
				<dl>
					<dt>比较符：</dt>
					<dd>
						<select name="compareTag" onchange="setExpression();" >
							<option value="=" <c:if test="${bean.compareTag==1}">selected</c:if> >等于</option>
							<option value=">" <c:if test="${bean.compareTag==2}">selected</c:if> >大于</option>
							<option value="<" <c:if test="${bean.compareTag==3}">selected</c:if> >小于</option>
							<option value="!=" <c:if test="${bean.compareTag==4}">selected</c:if>>不等于</option>
							<option value=">=" <c:if test="${bean.compareTag==5}">selected</c:if>>大于等于</option>
							<option value="<=" <c:if test="${bean.compareTag==6}">selected</c:if>>小于等于</option>
						</select>
					</dd>
				</dl>
				<dl>
					<dt>比较值：</dt>
					<dd><input name="compareVal" type="text" size="30" value="${bean.compareVal}" class="required" onchange="setExpression();" /></dd>
				</dl>
				<dl>
					<dt>权限：</dt>
					<dd>
						<select class="combox" name="power" onchange="setExpression();" >
							<option value="-1" <c:if test="${bean.power==-1}">selected</c:if> >隐藏</option>
							<option value="0" <c:if test="${bean.power==0}">selected</c:if> >未定义</option>
							<option value="1" <c:if test="${bean.power==1}">selected</c:if> >显示</option>
							<option value="2" <c:if test="${bean.power==2}">selected</c:if>>编辑</option>
						</select>
					</dd>
				</dl>
				<dl class="nowrap">
					<dt>判断表达式：</dt>
					<dd><textarea name="expression" cols="60" rows="3">${bean.expression}</textarea></dd>
				</dl>
				<dl class="nowrap">
					<dt>说明：</dt>
					<dd><textarea name="description" cols="60" rows="3">${bean.description}</textarea></dd>
				</dl>
			</fieldset>
		</div>
		<div class="formBar">
			<ul>
				<!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit" >保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">关闭</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript">
/**
 * dialog上的表单提交回调函数
 * 服务器转回navTabId，可以重新载入指定的navTab. statusCode=DWZ.statusCode.ok表示操作成功, 自动关闭当前dialog
 * form提交后返回json数据结构,json格式和navTabAjaxDone一致
 */
function dialogAjaxDone(json){
	DWZ.ajaxDone(json);
	if (json.statusCode == DWZ.statusCode.ok){
		if(json.callbackType){
			// 关闭本窗体
			$.pdialog.close("base_define_judge_add");
			// 重新打开父窗体
			var title = "选择操作";
			var url = "${path}/list.html";
			$.pdialog.open(url, "define_menu_judge_list", title,{width:800,height:480,mask:true,maxable:false,resizable:false});
		}
	}
}

function setExpression(){
	var dataName = $("input[name='dataName']").val();
	var compareTag = $("select[name='compareTag']").val();
	var compareVal = $("input[name='compareVal']").val();
	var power = $("select[name='power']").val();
	$("textarea[name='expression']").text("if(" + dataName+compareTag+compareVal + ") " + power);
}

</script>